#ifndef __SIM_SPI_H
#define	__SIM_SPI_H

// #include "stm32f10x.h"
// #include "Delay.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "stm32f10x.h"


//PB10->PWM_OUTPUT  TIM2_CH3  PB12->CSB	PB11->INT 	
//B13->SCK B14->MISO B15->MOSI

#define Sim_Spi_CE_H   GPIO_SetBits(GPIOB,GPIO_Pin_12) //LDC1000片选信号
#define Sim_Spi_CE_L   GPIO_ResetBits(GPIOB,GPIO_Pin_12) //LDC1000片选信号
#define Sim_Spi_CSB_H  GPIO_SetBits(GPIOB,GPIO_Pin_12) //SPI片选信号	   
#define Sim_Spi_CSB_L  GPIO_ResetBits(GPIOB,GPIO_Pin_12) //SPI片选信号
#define Sim_Spi_IRQ_H  GPIO_SetBits(GPIOB,GPIO_Pin_11)  //IRQ主机数据输入
#define Sim_Spi_IRQ_L  GPIO_ResetBits(GPIOB,GPIO_Pin_11)  //IRQ主机数据输入
#define Sim_Spi_MOSI_H GPIO_SetBits(GPIOB,GPIO_Pin_15) //MOSI
#define Sim_Spi_MOSI_L GPIO_ResetBits(GPIOB,GPIO_Pin_15) //MOSI
#define Sim_Spi_READ_MISO GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_14)//read MISO
#define Sim_Spi_SCK_H  GPIO_SetBits(GPIOB,GPIO_Pin_13)//SCK
#define Sim_Spi_SCK_L  GPIO_ResetBits(GPIOB,GPIO_Pin_13)//SCK

void Sim_Spi_SendAddress(uint8_t Addr);
uint8_t Sim_SpiSendData(uint8_t Data);
uint8_t Sim_Spi_ReadReg(uint8_t Addr);
uint8_t Sim_Spi_WriteReg(uint8_t Addr, uint8_t Data);



void Sim_Spi_ReadBytes(uint8_t Addr, uint8_t * Buf,uint8_t Len);
/*char Sim_Spi_ReadWord(char Addr, unsigned int * Data);  // Big Endian
char Sim_Spi_ReadBytes(char Addr, char * buffer, unsigned char Len);
char Sim_Spi_WriteByte(char Addr, char Data);
char Sim_Spi_WriteWord(char Addr, unsigned int Data);  // Big Endian
char Sim_Spi_WriteBytes(char Addr, char * Buffer, unsigned char Len);*/

#ifdef __cplusplus
}
#endif
#endif
